package org.zecontech.extraplus.datagen;

import net.minecraft.core.HolderLookup;
import net.minecraft.data.PackOutput;
import net.minecraft.tags.BlockTags;
import net.neoforged.neoforge.common.Tags;
import net.neoforged.neoforge.common.data.BlockTagsProvider;
import org.zecontech.extraplus.ExtraPlus;
import org.zecontech.extraplus.block.HerbBlock;
import org.zecontech.extraplus.init.ModBlockTagKeys;
import org.zecontech.extraplus.init.ModBlocks;
import org.zecontech.extraplus.util.Helpers;

import java.util.concurrent.CompletableFuture;

/**
 * 模组方块标签数据生成提供者
 */
public class ModBlockTagsProvider extends BlockTagsProvider {

    public ModBlockTagsProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> lookupProvider) {
        super(output, lookupProvider, ExtraPlus.MOD_ID);
    }

    /**
     * 添加标签
     * @param provider 提供者
     */
    @Override
    protected void addTags(HolderLookup.Provider provider) {
        tag(ModBlockTagKeys.ORE_REPLACEABLES)
                .addTags(BlockTags.STONE_ORE_REPLACEABLES)
                .addTags(BlockTags.DEEPSLATE_ORE_REPLACEABLES)
                .addTags(BlockTags.NETHER_CARVER_REPLACEABLES)
                .addTags(BlockTags.OVERWORLD_CARVER_REPLACEABLES);
        ModBlocks.BLOCKS.getEntries().forEach(block -> {
            if (Helpers.getBlockName(block.get()).contains("ore")) {
                tag(Tags.Blocks.ORES).add(block.get());
            } else if (block.get() instanceof HerbBlock herbBlock) {
                tag(Tags.Blocks.FLOWERS).add(herbBlock);
            }
        });
    }
}
